//schedule.js
const app = getApp()
const util = require('../../utils/util.js')
const lbbService = require('../service/service.js')

Page({
  data: {
    personalReportList: []
  },
  onLoad: function (options) {
    this.setData({
      scrollHeight: app.getScrollHeight(0)
    })
    if(options.hospitalId){
      this.setData({
        hospitalId:options.hospitalId
      })
    }
  },
  onReady: function () {
    // Do something when page ready.
  },
  onShow: function () {
    let that = this
    lbbService.getPersonalReports({},function(res){
      that.setData({
        personalReportList: res
      })
      if (that.data.hospitalId) {
        that.filterList()
      }
    })
  },
  onHide: function () {
    // Do something when page hide.
  },
  onUnload: function () {
    // Do something when page close.
  },
  filterList:function(){
    let that = this
    let personalReportList = that.data.personalReportList.filter(item => item.hospitalId ==that.data.hospitalId)
    that.setData({
      personalReportList: personalReportList
    })
  }
})